import { observable, action, toJS } from 'mobx';
import * as OutDetail from '../apis/outDetail';
import { message, Modal } from 'antd';
import { WeaTableNew } from 'comsMobx';

const { TableStore } = WeaTableNew;
import { WeaTools } from 'ecCom';

class OutDetailStore {
  @observable loading= false;
  @observable basicInfo = { docSubject: '' };
  @observable doccontent = '';
  @observable tabInfo= [];
  @observable tabKey= 'content';
  @observable dataKeys= {};
  @observable attrDatas= [];
  constructor() {
  }

  /**
   * 列表信息
   * */
  @observable accTableStore = new TableStore();// 附件

  @action
  getBasic = (params = {}) => {
    this.loading = true;
    OutDetail.getBasic(params).then(action((data) => {
      this.basicInfo = data.data || {};
      this.loading = false;
    }));

    OutDetail.getTabInfo(params).then(action((data) => {
      this.tabInfo = data.tabInfo;
    }));
  };

  @action
  getContent = (params = {}) => {
  	OutDetail.getContent(params).then(action((data) => {
  		this.doccontent = data.content;
  	}));
  }

  @action
  setTabKey = (tabKey = 0) => {
    this.tabKey = tabKey;
  };


  @action
  searchAcc = (params) => {
    this.loading = true;
    OutDetail.getAccTable(params).then(action((result) => {
      this.accTableStore.getDatas(result.sessionkey, params.current || 1);
      this.loading = false;
    }));
  }
}

export default OutDetailStore;
